//
//  UIPopView.m
//  TTAddressBook
//
//  Created by iphonekf2 on 12-1-18.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "UIPopView.h"
#import "imagePath.h"
#import "define.h"

@implementation UIPopView

- (void) setLabelText:(NSString*) text;{
    Label.text = text;
}
- (id)initWithFrame:(CGRect)frame andImageName:(NSString*)ImageName  andLabelText:(NSString*) LabelText andFont:(UIFont*) font andIsStretch:(BOOL) StretchAble{
    
    self = [self initWithFrame:frame];
    self.backgroundColor = [UIColor clearColor];
    BackGround = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
    BackGround.backgroundColor = [UIColor clearColor];
    if (StretchAble)
        BackGround.image = [[UIImage imageNamed:ImageName] stretchableImageWithLeftCapWidth:5 topCapHeight:5];
    else
        BackGround.image = [UIImage imageNamed:ImageName];  
    BackGround.alpha = 0.9;
    [self addSubview:BackGround];
    [BackGround release]; 
    if (LabelText != nil) {
        Label = [[UILabel alloc] initWithFrame: BackGround.frame];
        Label.text = LabelText;
        Label.backgroundColor = [UIColor clearColor];
        [Label setFont:font];    
        Label.textColor = [UIColor whiteColor];
        Label.textAlignment = UITextAlignmentCenter;
        [self addSubview:Label];
        [Label release];
    }
    return self;   
}

- (void) set_frame : (CGRect) frame{
    [super setFrame:frame];
    self.frame = frame;
    BackGround.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
    Label.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
}
- (void) setImagePath:(NSString*) ImagePath{
    BackGround.image = nil;
    BackGround.image = [UIImage imageNamed:ImagePath];
}
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code    
    }
    return self;
}


-(void) dealloc{
    
}



/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect
 {
 // Drawing code
 }
 */

@end
